/*
 * @lc app=leetcode.cn id=824 lang=javascript
 *
 * [824] 山羊拉丁文
 */

// @lc code=start
/**
 * @param {string} S
 * @return {string}
 */
var toGoatLatin = function(S) {
    let test="aAeEiIoOuU"
    let arr=S.match(/[a-zA-Z]+/g)
    for(let i=0;i<arr.length;i++){
        if(test.includes(arr[i][0])){
            arr[i]+="ma"
        }else{
            arr[i]=arr[i].slice(1)+arr[i][0]+"ma"
        }
        arr[i]=arr[i]+"a".repeat(i+1)
    }
    return arr.join(" ")
};
// @lc code=end

